﻿using System;
using System.Collections.Generic;
using System.Configuration;

namespace EditorialProyectos.Website.Infrastructure
{
    public class Utils
    {
        public static bool VerifyAuthorizationKey(Dictionary<string, bool> dictionary, string key)
        {
            var authorizationValidation = Convert.ToBoolean(ConfigurationManager.AppSettings["AuthorizationValidation"]);

            if (authorizationValidation)
            {
                if (dictionary != null)
                {
                    key = key.ToLower();
                    if (dictionary.ContainsKey(key))
                        return dictionary[key];

                    return false;
                }

                return false;
            }

            return true;
        }
    }
}